const getDetailLocation = (
  target: HTMLElement | null
):
  | ""
  | "start"
  | "end"
  | { location: string; key?: string; target?: HTMLElement } => {
  if (target === null) {
    return "";
  }
  if (target?.className === "render-container") {
    return "end";
  }
  if (target?.id === "main") {
    return "start";
  }
  if (target?.dataset?.location === undefined) {
    return getDetailLocation(target?.parentElement);
  } else {
    return {
      location: target?.dataset?.location,
      key: target?.dataset?.key || "",
      target,
    };
  }
};

export default getDetailLocation;
